<template>
  <div class="cate">
    <div class="read-top">
      <router-link :to="{ path: '/' }">
        <div class="backbox"><img src="../assets/back.png" alt="" /></div>
      </router-link>
      <div class="mulu">目录</div>
    </div>
    <div class="novalbox">
      <div class="imgbox"><img :src="neirong.coverImage" alt="" /></div>
      <div class="rightbox">
        <div class="title">{{neirong.title}}</div>
        <div class="zuozhe">{{neirong.author}}</div>
      </div>
    </div>
    <div class="zhangjie">共{{novallength}}章</div>
    <div class="listbox">
      <div class="zhengwen">正文</div>
      <ul class="list">
        <router-link :to="{path :'/',query:{id:uuid}}"></router-link>
        <li v-for="item in novalarr" :key="item.uuid">{{item.title}}</li>
      </ul>
    </div>
  </div>
</template>

<script>
import { get } from "../http/request";
export default {
  name: "catelogue",
  data() {
    return {
      uuid: "",
      neirong:"",
      novallength:"",
      novalarr:"",
    };
  },
  methods: {
    async getcatelogue(data) {
      await get(
        `https://apis.netstart.cn/yunyuedu/reader/book/info.json`,
        data
      ).then((res) => {
        console.log(res);
        
        this.novallength = res.data.catalog.length;
        
        this.neirong = res.data.book;

        this.novalarr = res.data.catalog;
        console.log(this.novalarr);

      });
    },
  },
  created() {
    // 获取传递过来的id
    this.uuid = this.$route.query.id;
    console.log(this.uuid);
    

    // 调用获取数据的方法
    this.getcatelogue({ source_uuid: this.uuid });
  },
};
</script>

<style lang="scss" scoped>
.cate {
  width: 100%;
  font-size: 16px;
  .read-top {
    width: 100%;
    height: 50px;
    background-color: rgb(255, 252, 252);
    display: flex;
    // justify-content: space-between;
    position: relative;
    .backbox {
      width: 50px;
      height: 50px;
      text-align: center;
      img {
        width: 30px;
        height: 30px;
        margin-top: 10px;
      }
    }
    .mulu {
      height: 50px;
      text-align: center;
      line-height: 50px;
      position: absolute;
      left: 155px;
      font-size: 20px;
    }
  }
  .novalbox {
    width: 100%;
    padding: 0 15px;
    font-size: 16px;
    display: flex;
    .imgbox {
      width: 100px;
      height: 150px;
      img {
        width: 100px;
        height: 150px;
      }
    }
    .rightbox {
      width: 200px;
      // height: 150px;
      margin-left: 20px;
      margin-top: 30px;
      .title {
        font-size: 20px;
        color: black;
        
      }
      .zuozhe {
        color: gray;
        margin-top: 10px;
      }
    }
  }
  .zhangjie {
    padding: 0 15px;
    font-size: 16px;
    margin-top: 15px;
  }
  .listbox {
    width: 100%;
    // padding: 0 15px; 
    .zhengwen {
      background-color: #F9F9F9;
      color: gray;
      padding: 0 15px;
      height: 30px;
      line-height: 30px;
    }
    .list {
      padding: 0 30px;
      li {
        height: 50px;
        line-height: 50px;
        border-bottom: 1px dotted gainsboro;
      }
    }
  }
}
</style>